package com.mlf.prototype.spring;

import lombok.Data;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
@Scope("prototype")
@Data
public class PrototypeBean {

    public static int instantCount = 0;// 静态变量，属于类而非实例
    private final int instanceId;  // 实例变量，每个实例独立

    public PrototypeBean() {
        instanceId = ++instantCount; // 每次创建新实例时递增静态计数器
    }

    public String getInstanceId() {
        return "PrototypeBean Instance ID: " + instanceId;
    }

}
